<?php

namespace App\Admin\Controllers;

use App\Models\Grade;
use App\Models\ClassCourse;
use App\Models\Teacher;
use App\Models\Student;
use App\Models\Semester;
use App\Http\Controllers\Controller;
use Encore\Admin\Controllers\HasResourceActions;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use App\Models\Details;
use Encore\Admin\Layout\Content;
use Encore\Admin\Show;
use Encore\Admin\Facades\Admin;
use App\admin\Extensions\InsertTCQE;
use App\Admin\Extensions\ScoreHandle;
use App\Models\Course;
use Illuminate\Http\Request;


class StudentCQEController extends Controller
{
    use HasResourceActions;

    /**
     * Index interface.
     *
     * @param Content $content
     * @return Content
     */
    public function index()
    {
        $user_id = Admin::user()->id;
        $student = Student::where('user_id', $user_id)->first();
        $student_id = $student->id;

        $semester = Semester::where('is_semester', 1)->first();
        $semester_id = $semester->id;

        $judge = Details::where('student_id', $student_id)->where('appraiser', $user_id)->where('semester_id', $semester_id)->where('appraiser_type', '3')->first();
        if (empty($judge)) {
            return redirect('admin/cqe/detail?id=' . $student_id . '&type=3');
        } else {
            // 提示 然后 跳转到 个人综合评价详情页面
            //显示模板及数据
            $data = [
                'message' => '本学期已评价',
                'url' => 'list',
                'jumpTime' => 3,
                'status' => 'status'
            ];
            return view('/admin/cqe/prompt', ['data' => $data]);
        }


    }

    public function result()
    {
        $user_id = Admin::user()->id;
        $student = Student::where('user_id', $user_id)->first();
        $student_id = $student->id;

        return redirect('admin/cqe/result?id=' . $student_id);
    }
}